﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace Hermes.Common
{
    public class EUBHelper
    {
        public static string ToEUBOrdersMessage(Hermes.Model.Orders order)
        {
            string itemMessage = "";

            foreach (Hermes.Model.OrderLines line in order.OrderLines)
            {
                itemMessage += @"<item>
				                    <enname>" + line.SKU + @"</enname>
				                    <count>" + line.QTY + @"</count>
				                    <weight>" + 50 + @"</weight>
				                    <delcarevalue>" + 5 + @"</delcarevalue>
				                    <origin>CN</origin>
			                    </item>";
            }

            string message = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                + "<orders xmlns:xsi=\"" + "http://www.w3.org/2001/XMLSchema-instance" + "\">"
                + "<order>"
                + "<orderid>" + order.OrderNumber + "</orderid>"
                + "<customercode>" + order.OrderNumber + "</customercode>"
                + "<vipcode>00000000000001</vipcode>"
                + "<clcttype>1</clcttype>"
                + "<pod>false</pod>"
                + "<untread>Abandoned</untread>"
                + "<volweight>121</volweight>"
                + "<startdate>" + DateTime.Now.ToString("s") + "</startdate>"
                + "<enddate>" + DateTime.Now.ToString("s") + "</enddate>"
                + "<printcode>0</printcode>"
                + @"<sender>
			        <name>liutao</name>
			        <postcode>100055</postcode>
			        <phone>2131231</phone>
			        <mobile>13923400496</mobile>
			        <country>CN</country>
			        <province>441402</province>
			        <city>441402</city>
			        <county>441402</county>
			        <company>lc</company>
			        <street>liuxiandadao 126</street>
			        <email>liutao0116@gmail.com</email>
		        </sender>"
                + "<receiver>"
                + "<name>" + order.Contact + "</name>"
                + "<postcode>" + order.Postcode + "</postcode>"
                + "<phone>" + order.Phone + "</phone>"
                + "<mobile>" + order.Phone + "</mobile>"
                + "<country>UNITED STATES OF AMERICA</country>"//" + order.Country + "
                + "<province>" + order.Province + "</province>"
                + "<city>" + order.City + "</city>"
                + "<county/>"
                + "<street>" + order.Street + "</street>"
                + "</receiver>"
                + @"<collect>
			        <name>王大琳</name>
			        <postcode>100067</postcode>
			        <phone>123456-908-098</phone>
			        <mobile>1233333333333</mobile>
			        <country>CN</country>
			        <province>441402</province>
			        <city>441402</city>
			        <county>441402</county>
			        <company/>
			        <street>123 126</street>
			        <email>xafsadf@eeasdfasdfasdfasdfasdfasdfasdfasdfasdfasdds.com</email>
		        </collect>"
                + "<items>"
                + itemMessage
                + "</items>"
                + @"<remark/>
	                </order>
                </orders>";
            return message;
        }

        public static string ToEUBGetLabelMessage(Hermes.Model.WebService.UnLabelOrderInfo[] orders)
        {
            string trackingNOMessage = "";


            foreach (Hermes.Model.WebService.UnLabelOrderInfo o in orders)
            {
                trackingNOMessage += @"<order><mailnum>" + o.TrackingNo + "</mailnum></order>";

            }

            string message = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                + "<orders xmlns:xsi=\"" + "http://www.w3.org/2001/XMLSchema-instance" + "\">"

                + trackingNOMessage

                + @"    
                </orders>";
            return message;
        }

    }
}
